{extend name="main/index" /}
{block name="main"}
<!-- Start right content -->
<div class="content-page">
    <!-- ============================================================== -->
    <!-- Start Content here -->
    <!-- ============================================================== -->
    <div class="content">
        <!-- Page Heading Start -->
        <div class="page-heading">
            <h1><i class='fa fa-table'></i> 节点管理</h1>
            <h3>节点列表</h3></div>
        <!-- Page Heading End-->                <!-- Your awesome content goes here -->
        <div class="row">

            <div class="col-md-12">
                <div class="widget">
                    <div class="widget-header transparent">
                        <h2><strong>节点列表</strong> Table</h2>
                        <div class="additional-btn">
                            <a href="#" class="hidden reload"><i class="icon-ccw-1"></i></a>
                            <a href="#" class="widget-toggle"><i class="icon-down-open-2">

                            </i></a>
                            <a href="#" class="widget-close"><i class="icon-cancel-3"></i></a>
                        </div>
                    </div>
                    <div class="widget-content">
                        <div class="table-responsive">
                            <table data-sortable class="table">
                                <thead>
                                <tr>
                                    <th>ID</th>
                                    <th style="width: 30px" data-sortable="false">
                                        <input type="checkbox" class="rows-check"></th>
                                    <th>节点名称</th>
                                    <th>模块名(控制器)</th>
                                    <th>操作</th>
                                    <th>状态</th>
                                    <th data-sortable="false">操作</th>
                                </tr>
                                </thead>

                                <tbody>
                                {volist name="list" id="v"}

                                <tr>
                                    <td>{$v['id']}</td>
                                    <td><input type="checkbox" class="rows-check"></td>
                                    <td><strong>{$v['name']}</strong></td>
                                    <td>{$v['mname']}</td>
                                    <td>{$v['aname']}</td>
                                    <td>{$v['status'] == 1? '启用' : '禁用'}</td>
                                    <td>
                                        <!-- <div class="btn-group btn-group-xs"> -->
                                        <button data-id="{$v['id']}" class="btn btn-default del-btn">删除</button>
                                        <a href="{:url('admin/Node/edit', ['id'=>$v['id']])}" data-toggle="tooltip" title="" class="btn btn-default">编辑</a>
                                        <!-- </div> -->
                                    </td>
                                </tr>
                                {/volist}
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        </div>



    </div>


</div>

{js href="/static/index/js/jquery.min.js"}


<script>

    $('.del-btn').click(function () {
        var ac_id = $(this).attr('data-id');
        console.log('删除 ID: ' + ac_id + '的用户');

        if (confirm('你确定要 [ 删 除 ] 吗?')) {
            var obj = $(this).parents('tr');
            // console.log(obj);
            // 调用AJAX删除
            delAjax(ac_id, obj);
        }
    });
    function delAjax(id, obj) {
        $.ajax({
            type: 'delete',
            url: '/node/' + id,
            dataType: 'json',
            success: function (data) {

                if (data.status) {
                    alert(data.info);
                    obj.remove();
                } else {
                    alert(data.info);
                }
            },
            error: function (err) {
                alert('删除失败');

            }
        });
    }



</script>


{/block}